package leetCode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class MergeList {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });

    }
    public class ListNode {
      int val;
      ListNode next;
      ListNode() {}
      ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }

    public ListNode mergeKLists(ListNode[] lists) {
        int[] nums = new int[100];
        int index = 0;
        for(int i = 0;i<lists.length;i++){
            ListNode temp = lists[i];
            while(temp != null){
                nums[index] = temp.val;
                index++;
            }
        }
        Arrays.sort(nums);
        ListNode head = new ListNode();
        ListNode p = head;
        for(int num : nums){
            p.val = num;
            p = p.next;
        }
        p=null;
        return head;
//        List<Integer> l = new ArrayList<>();
    }
    }

